{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution:\n",
    "    def detectCapitalUse(self, word: str) -> bool:\n",
    "        uppercase = set([chr(x) for x in range(ord('A'), ord('Z')+1)])\n",
    "        lowercase = set([chr(x) for x in range(ord('a'), ord('z')+1)])\n",
    "        \n",
    "        s_w = set(word)\n",
    "        \n",
    "        if uppercase & s_w == s_w:\n",
    "            return True\n",
    "        if lowercase & s_w == s_w:\n",
    "            return True\n",
    "        \n",
    "        s_w = set(word[1:])\n",
    "        if word[0] in uppercase and s_w & lowercase == s_w:\n",
    "            return True\n",
    "        \n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.detectCapitalUse('Usb')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
